package com.zxy.study.ui.activity;

import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.zxy.study.R;
import com.zxy.study.ui.widget.AutoVerticalScrollTextView2;
import com.zxy.study.ui.widget.BlueBannerView;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : Shonn.Zhang
 * @email : shonn.zhang@mart.blue
 * @time : 2020/9/4 15:56
 * @desc :
 */
public class ViewPager2Activity extends AppCompatActivity {

    private int[] imgRes = new int[]{R.mipmap.bg_head, R.mipmap.bg_head, R.mipmap.bg_head, R.mipmap.bg_head};
    private ImageView[] imageViews = new ImageView[4];

    private AutoVerticalScrollTextView2 mNoticeView;
    private BlueBannerView mBannerView;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_viewpager2);
        initView();
    }

    private void initView() {
        mNoticeView = findViewById(R.id.view_notice);
        mBannerView = findViewById(R.id.view_banner);

        initNoticeVp2();
        initBanner();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    private void initNoticeVp2() {
        List<ScrollText> dataList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            dataList.add(new ScrollText("" + i, "排牙排牙打哈吉" + i, "" + i));
        }

        mNoticeView.setScrollTextList(dataList);
        mNoticeView.setOnScrollTextListener(new AutoVerticalScrollTextView2.onScrollTextListener() {
            @Override
            public void onTextClick(String nowClickUrl, String id) {
                Log.i("AAA", "onTextClick=" + nowClickUrl);
            }

            @Override
            public void onTextShow(int pos) {
                Log.i("AAA", "onTextShow=" + pos);
            }
        });
        mNoticeView.start();
    }

    private void initBanner(){
        List<String> urlList = new ArrayList<>();
        urlList.add("https://bluepms.oss-ap-southeast-1.aliyuncs.com/thtest/res/img/3e8cc2dbb5a4dec340a100723998bcac.png");
        urlList.add("https://bluepms.oss-ap-southeast-1.aliyuncs.com/thtest/res/img/f30a4186e4711af06385fcf41d574624.png");

        mBannerView.setData(urlList);
        mBannerView.startAutoPlay();
    }

    public class ScrollText implements AutoVerticalScrollTextView2.IScrollText {

        private String id;
        private String text;
        private String url;

        public ScrollText(String id, String text, String url) {
            this.id = id;
            this.text = text;
            this.url = url;
        }

        @Override
        public String getId() {
            return id;
        }

        @Override
        public String getScrollText() {
            return text;
        }

        @Override
        public String getClickUrl() {
            return url;
        }
    }


}
